package cn.stu.cms.controller;


import cn.stu.cms.dto.SetTeamDto;
import cn.stu.cms.pojo.Employees;
import cn.stu.cms.service.EmployeesService;
import cn.stu.cms.util.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;

/**
 * (Employees)表控制层
 *
 * @author gh
 * @since 2023-07-21 15:18:42
 */
@RestController
@RequestMapping("/employees")
@AllArgsConstructor
public class EmployeesController {

    private final EmployeesService employeesService;

    @GetMapping("/list")
    public R<List<Employees>> getList() {
        return R.ok(employeesService.list());
    }

    /**
     * 设置团队
     *
     * @param setTeamDto 将团队数据设置为
     * @return {@link R}<{@link Boolean}>
     */

    @PostMapping("/setTeam")
    public R<Boolean> setTeam(@RequestBody @Valid SetTeamDto setTeamDto) {
        return employeesService.setTeam(setTeamDto);
    }

    @PutMapping("/setPhone")
    public R<Boolean> setPhone(@RequestParam String phone) {
        return employeesService.setPhone(phone);
    }


    @PostMapping(value = "/uploadAvatar")
    public R<String> fileUpload(@RequestParam(required = false, name = "file") MultipartFile file) {
        return employeesService.fileUpload(file);
    }
}

